package com.cskaoyan.market.controller;

import com.cskaoyan.market.db.domain.MarketCollect;
import com.cskaoyan.market.service.MarketCollectService;
import com.cskaoyan.market.service.MarketCollectServiceImpl;
import com.cskaoyan.market.util.JacksonUtil;
import com.cskaoyan.market.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author: YaLiFeng
 * @description: TODO
 * @date: 2024/5/7 10:47
 */
@RestController
@RequestMapping("/admin/collect")
public class AdminCollectController  {
    @Autowired
    private MarketCollectService marketCollectService;


    @GetMapping("list")
    public Object list(String page,String limit,String sort,String order,String userId,String valueId) {
        Integer pageParam=null;
        Integer limitParam=null;
        try{
            pageParam=Integer.parseInt(page);
            limitParam=Integer.parseInt(limit);
        }catch(NumberFormatException e){
            Object object= ResponseUtil.badArgument();
            return ResponseUtil.fail();
        }
        List<MarketCollect> marketCollects=marketCollectService.list(pageParam,limitParam,sort,order,userId,valueId);
        return ResponseUtil.okList(marketCollects);
    }
}
